//
//  MyCollectionCell.m
//  敢唆嘛!
//
//  Created by 教主 on 15/11/28.
//  Copyright © 2015年 zms. All rights reserved.
//

#import "MyCollectionCell.h"
#import "Device.h"

@interface MyCollectionCell ()
//@property(nonatomic, strong)UIImageView *userHeaderImage;
@property(nonatomic, strong)UILabel *userNameLabel;
@property(nonatomic, strong)UILabel *createdAt;
@property(nonatomic, strong)UILabel *infoTitle;
@end

@implementation MyCollectionCell
{
    CGFloat x;
    CGFloat y;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        x = KSWidth / 19;
        y = KSWidth / 19;
        
        self.userNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(x, y / 2, KSWidth / 3, KSWidth / 10)];
        self.userNameLabel.alpha = 0.8;
        self.userNameLabel.textColor = [UIColor blackColor];
        self.userNameLabel.font = [UIFont systemFontOfSize:KSWidth / 28];
        [self.contentView addSubview:_userNameLabel];
        
        self.infoTitle = [[UILabel alloc] initWithFrame:CGRectMake(self.userNameLabel.frame.size.width + x, y / 2, KSWidth / 3, KSWidth / 10)];
        self.infoTitle.alpha = 0.8;
        self.infoTitle.textColor = [UIColor blackColor];
        self.infoTitle.font = [UIFont systemFontOfSize:KSWidth / 28];
        [self.contentView addSubview:_infoTitle];
        
        self.createdAt = [[UILabel alloc] initWithFrame:CGRectMake(self.userNameLabel.frame.size.width + x * 1.5 + self.infoTitle.frame.size.width, y / 2, KSWidth / 3, KSWidth / 10)];
        self.createdAt.alpha = 0.8;
        self.createdAt.textColor = [UIColor blackColor];
        self.createdAt.font = [UIFont systemFontOfSize:KSWidth / 28];
        [self.contentView addSubview:_createdAt];
    }
    return self;
}

- (void)setModel:(MyCollectModel *)model
{
    self.userNameLabel.text = [NSString stringWithFormat:@"作者: %@",model.userName];
    self.infoTitle.text = model.infoTitle;
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    formatter.dateFormat = @"yyyy-MM-dd HH:mm:ss";//日期格式
    NSDate *date = [formatter dateFromString:model.createdAt];
    self.createdAt.text = [[PrettyDate alloc] prettyDateWithReference:date];

}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
